<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="../lib/jquery/jquery-1.12.4.min.js"></script>
<script src="./url.js"></script>
<style>
    p {
        width: 200px;
        height: 30px;
        line-height: 30px;
        border-radius: 5px;
        text-align: center;
        background: #1BA292;
        color: white;
        margin-bottom: 30px;
    }

    input {
        margin-bottom: 25px;
    }

    button {
        border: 0;
        background: #71B604;
        color: white;
        width: 80px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        border-radius: 5px;
    }
</style>

<body>
    <p>员工信息录入</p>
    员工编号： <input type="text" name="employee_id" class="employee_id"><br>
    员工姓名： <input type="text" name="employee_name" class="employee_name"><br>
    员工职位： <input type="text" name="employee_zhiwei" class="employee_zhiwei"><br>
    电话： <input type="text" name="phone" class="phone"><br>
    邮箱： <input type="text" name="email" class="email"><br>
    <button>添加</button>
    <script>
        $("button").click((e) => {
            e.preventDefault()
            $.ajax({
                method: "post",
                url: `${Baseurl}/staff`,
                data: {
                    employee_id: $(".employee_id").val(),
                    employee_name: $(".employee_name").val(),
                    employee_zhiwei: $(".employee_zhiwei").val(),
                    phone:$(".phone").val(),
                    email:$(".email").val()
                },
                success: function (data) {
                    console.log(data);
                    if(data=="员工信息录入成功"){
                        alert(data)
                        window.location="./index.html"
                    }
                },
                error: function (err) {
                    console.log(err);
                }
            })
        })
    </script>
</body>

</html>